package com.yxhl.zoume.core.user.ui.adapter;

import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yxhl.zoume.R;
import com.yxhl.zoume.data.http.model.mywallet.TradeRecordBean;

import java.util.List;


/**
 * Created by vhawk on 2016/11/11.
 */

public class IncomeExpensesAdapter extends BaseQuickAdapter<TradeRecordBean, IncomeExpensesAdapter.IncomeExpensesViewHolder> {

    public IncomeExpensesAdapter(List<TradeRecordBean> tradeRecordsList) {
        super(R.layout.item_income_expenses, tradeRecordsList);
    }

    @Override
    protected void convert(IncomeExpensesViewHolder viewHolder, TradeRecordBean tradeRecordBean) {
        viewHolder.setText(R.id.tv_inex_vehicle_type, tradeRecordBean.getTradeType())
                .setText(R.id.tv_inex_money, tradeRecordBean.getFee())
                .setText(R.id.tv_inex_time, tradeRecordBean.getTradeTime());
        viewHolder.bindData(tradeRecordBean);
    }

    @Override
    protected IncomeExpensesViewHolder createBaseViewHolder(View view) {
        return new IncomeExpensesViewHolder(view);
    }

    class IncomeExpensesViewHolder extends BaseViewHolder {

//        @BindView(R.id.tv_inex_vehicle_type)
//        TextView mTvInexVehicleType;
//        @BindView(R.id.rl_inex_item)
//        RelativeLayout mRlInexItem;
//        @BindView(R.id.tv_inex_money)
//        TextView mTvInexMoney;
//        @BindView(R.id.tv_inex_time)
//        TextView mTvInexTime;

        private String tradeType;
        private String orderSerial;
        private final TextView mMTvMoney;

        public IncomeExpensesViewHolder(View itemView) {
            super(itemView);
            mMTvMoney = (TextView) itemView.findViewById(R.id.tv_inex_money);

//            ButterKnife.bind(this, itemView);
        }

        public void bindData(TradeRecordBean tradeRecordBean) {
//            if (null != tradeRecordBean) {
////                mTvInexVehicleType.setText(tradeRecordBean.getTradeType());
////                mTvInexMoney.setText(tradeRecordBean.getFee());
////                mTvInexTime.setText(tradeRecordBean.getTradeTime());
//                tradeType = tradeRecordBean.getTypeOfTrade();
//                orderSerial = tradeRecordBean.getId();
//                //”USER_RECHARGE”:充值、”USER_PAY”:支付、”USER_REFUND”:退款、”USER_RECHARGE_AND_PAY”:支付
            switch (tradeRecordBean.getTypeOfTrade()) {
                case "USER_PAY":
                case "USER_RECHARGE_AND_PAY":
                    mMTvMoney.setSelected(false);
                    break;
                case "USER_RECHARGE":
                case "USER_REFUND":
                    mMTvMoney.setSelected(true);
                    break;
            }
//            }
        }
    }
}
